<template>
	<view>
		<!-- operation 是一个变量，它的值应该是一个组件名或组件选项对象。Vue 会根据 operation 的值来决定渲染哪个组件。
		 ref 是 Vue.js 提供的一个特殊属性，用来给元素或子组件注册引用信息。通过 ref，你可以在 Vue 实例中通过 this.$refs.operation 访问这个组件的实例。-->
		<component :is="operation" ref='operation'></component> 
	</view>
</template>

<script>
	import {
		reqHouseId,
		reqGetStatu,
		reqGetHouseId
	} from '@/api/index.js'
	import {
		mapGetters
	} from 'vuex'
	import {
		debounce
	} from '@/utils/debounce.js'
	import nfc4 from '@/nfc4.js';
	import CagenumberLay from '@/pages/cagenumber-layEggs/cagenumber-layEggs.vue'
	import CagenumberWhip from '@/pages/cagenumber-whipEggs/cagenumber-whipEggs.vue'
	import CagenumberPut from '@/pages/cagenumber-putEggs/cagenumber-putEggs.vue'
	import CagenumberFeed from '@/pages/cagenumber-feedbirds/cagenumber-feedbirds.vue'
	import Expection from '@/pages/expection/expection.vue'
	import ExpectionHandle from '@/pages/expectionHandle/expectionHandle.vue'
	import AdHistory from '@/pages/ad-history/ad-history.vue'
	import AdDetail from '@/pages/ad-detail/ad-detail.vue'
	import Administrator from '../administrator/administrator.vue';
	import Warning from '@/pages/warning/warning.vue'
	import Putlist from '@/pages/putList/putList.vue'
	import HouseChange from '@/pages/house-change/house-change.vue'
	import HouseAdd from '@/pages/houseAdd/houseAdd.vue'
	export default {
		components: {
			CagenumberLay,
			CagenumberWhip,
			CagenumberPut,
			CagenumberFeed,
			Expection,
			ExpectionHandle,
			AdHistory,
			AdDetail,
			Administrator,
			Warning,
			Putlist,
			HouseChange,
			HouseAdd,
		},
		data() {
			return {
				formData: {
					siteId: '',
					houseId: ''
				},
				show: true,
				control: '',
				loading: true,
				debounceGetStatu: debounce(() => {
					this.getStatu()
				}, 200),
				debounceGetNFC: debounce(() => {
					this.nfcFn4()
				})
			}
		},
		async onLoad() {
			this.control = uni.getStorageSync('control')
		},
		computed: {
			...mapGetters(['isShow', 'cageStatu', 'requests', 'open', 'operation','nfcId'])
		},
		methods: {
			// async nfcFn4() {
			// 	return new Promise((resolve, reject) => {
			// 		const success = (data) => {
			// 			console.log('success', data);
			// 			// this.testNFC(data)
			// 			resolve({
			// 				msg: 'success',
			// 				nfcId: data,
			// 				isShow: false
			// 			});
			// 			console.log('返回了promise')
			// 			// resolve(data)
			// 		};
			// 		const fail = (err) => {
			// 			console.log('fail', err);
			// 			reject({
			// 				msg: 'error',
			// 				errMsg: err,
			// 			});
			// 			// reject(err)
			// 		};
			// 		const complete = () => {
			// 			console.log('?');
			// 		};
			// 		nfc4.nfcGetId({
			// 			success,
			// 			fail,
			// 			complete,
			// 		});
			// 	});
			// },
			// async testNFC() {
			// 	const res = await this.nfcFn4();
			// 	console.log('res', res)
			// 	if (res.msg === 'success') {
			// 		this.show = res.isShow
			// 		console.log('一开始的nfcId', this.nfcId)
			// 		const nfcId = res.nfcId.toString();
			// 		this.nfcId = nfcId
			// 		this.$store.commit('SETNFC', nfcId);
			// 		console.log('setnfc传递的nfcId', nfcId);
			// 		console.log('setnfc之后的nfcId,从仓库获取', this.nfcId);
			// 		return new Promise(resolve => {
			// 			resolve({
			// 				msg: '读取成功',
			// 				nfcId: nfcId,
			// 				// 不显示nfc页面
			// 				// isShow: false
			// 			})
			// 		})
			// 	} else if (res.msg === 'error') {
			// 		uni.showToast({
			// 			title: `读取失败:${res.errMsg}`,
			// 			icon: 'none',
			// 		});
			// 	} else if (res.msg === 'complete') {}
			// }
		}
	}
</script>

<style lang="scss" scoped>
</style>